/**   
* @Title: CORSResponseFilter.java 
* @Package: com.ifuntimes.http
* @Description: TODO
* @author:YuHai
* @Email: it@ifuntimes.com  
* @date 2017年09月05日 下午7:57:55 
* @version V1.0   
*/
package com.ifuntimes.http;

import java.io.IOException;

import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.container.ContainerResponseFilter;
import javax.ws.rs.core.MultivaluedMap;

/**
 * @ClassName: CORSResponseFilter
 * @Description: TODO
 * @author it@ifuntimes.com
 * @date 2017年09月05日 下午7:57:55 
 * 
 */
public class CORSResponseFilter implements ContainerResponseFilter {

	public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
			throws IOException {

		MultivaluedMap<String, Object> headers = responseContext.getHeaders();

		headers.add("Access-Control-Allow-Origin", "*");
		// headers.add("Access-Control-Allow-Origin",
		// "http://podcastpedia.org"); //allows CORS requests only coming from
		// podcastpedia.org
		//headers.add("Access-Control-Allow-Methods", "GET, POST, DELETE, PUT");
		headers.add("Access-Control-Allow-Methods", "POST");
		headers.add("Access-Control-Allow-Headers", "X-Requested-With, Content-Type, X-Codingpedia");
	}

}
